package map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        String line = "hello world!thinking in java!i love java!";
        Map<Character, Integer> map = new HashMap<>();
        Character key;
        for (int i = 0; i < line.length(); i++) {
            if (map.containsKey(line.charAt(i))) {
                map.put(line.charAt(i), map.get(line.charAt(i)) + 1);
            } else{
                map.put(line.charAt(i), 1);
            }

        }
        Set<Map.Entry<Character, Integer>> set = map.entrySet();
        for (Map.Entry<Character, Integer> c : set) {
            Character k = c.getKey();
            Integer v = c.getValue();
            System.out.println(k + ":" + v);
        }

    }
}
